import axios from '@/core/utils/AxiosRequest'
import ThrottleRequest from '@/core/utils/ThrottleRequest'
// let queue = [] // 将需要批量更新的watcher 存放到一个列队中
// let has = {}
// let pending = false
/**
 * 系统-目录-接口
 */
const prefix = '/api/system/catalog'
export default {
    
  /**
   * 获取上级目录(节流请求)
   * @returns
   */
  getTreeOptions(type) {
    let payload = {type}
    //return axios.get(`${prefix}/getTreeOptions`, { params: payload })
    return ThrottleRequest(`${prefix}/getTreeOptions`, payload)
  },

  /**
   * 获取所数据记录
   * @returns
   */
  getListData(payload) {
    return axios.get(prefix + '/getListData', {params: payload})
  },

  /**
   * 获取分页表
   * @param {*} payload
   * @returns
   */
  getListByPage(payload) {
    return axios.get(prefix + '/getListDataByPage', { params: payload })
  },

  /**
   * 获取按ID获取表单信息
   * @param {*} id
   * @returns
   */
  getFormModelById(id) {
    return axios.get(prefix + '/getFormDataById?id='+id)
  },

  /**
   * 保存数据
   * @param {*} payload
   * @returns
   */
  saveData(payload) {
    return axios.post(prefix + '/saveData', payload)
  },

  /**
   * 多个key删除数据
   * @param {key[]} payload
   * @returns
   */
  removeData(payload) {
    return axios.get(prefix + '/delete', {params: payload})
  }
}